#ifndef __MYSQL_DATABASE_H__
  #define __MYSQL_DATABASE_H__

#include "database.h"

#include "winsock.h" // required by "mysql.h"
#include "mysql.h"

using namespace std;

//! Wrapper for MySQL database

/*!
This class is inherited from database and offers access to a MySQL database system.

Implementation date: 2008

Usage:

\code
record_set rs;
mysql_database md;
md.connect("127.0.0.1", "root", "passme", "test", "protocol_file.txt");
md.execute_query("SELECT * FROM \"T1\" LIMIT 10;", rs);
cout << rs << endl;
\endcode
*/

class mysql_database : public database {
private:
  MYSQL mysql;

public:
  virtual void connect(const string &connection_string, const string &protocol_file = global_empty_string);
  virtual void connect(const string &host, const string &user_id, const string &password, const string &db_name, const string &protocol_file = global_empty_string);
  virtual void disconnect();

  virtual bool is_connected();

  virtual void execute_query(const string &s, record_set &rs, bool append_to_record_set = false);
  virtual void execute_update(const string &s);

  virtual void start_transaction();
  virtual void commit();
  virtual void rollback();

  virtual void lock_table(const string &table_name);
  virtual void unlock_table(const string &table_name);

  //! default constructor
  mysql_database();

  //! destructor
  virtual ~mysql_database();
}; // class mysql_database

#endif
